<?php
namespace app\controller;

use app\BaseController;

class Index extends BaseController
{
    private $result = [];
    private $num = 0;
    public function index()
    {
      //  return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V6<br/><span style="font-size:30px">13载初心不改 - 你值得信赖的PHP框架</span></p></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="eab4b9f840753f8e7"></think>';
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }

    public function abc(){
        echo 111;
    }

    private function combination($str,$tmp){

        $long = strlen($str);
        if ($long == 0) $this->result[] = $tmp;
        for ($i = 0; $i < $long; $i++)
        {
           // 首次循环已经将 tem=a,b,c,d 开头代了进去
           $this->combination(str_replace($str[$i], "", $str), $tmp . $str[$i]);

        }

    }

    private function combination2($str,$tmp){

        $long = strlen($str);
        if ($long == 0) $this->result[] = $tmp;
        for ($i = 0; $i < $long; $i++)
        {
            $a=$str[$i];
            $arr = str_split($str);
            unset($arr[$i]);
            $str2 = implode("",$arr);
            unset($arr);
            $this->combination2($str2,$tmp.$a);
            unset($str2);
        }

    }

    public function show(){
        $str = 'ababc';
        $this->combination2($str,"");
        $result = array_unique($this->result);
        $arr = [];
       foreach ($result as $v){
           if (strrev($v) == $v){
               $arr[] = $v;
           }
       }
       print_r($arr);
    }

    public function checkStr(){

        $str = 'aba';
        echo strrev($str);

    }

}
